package com.gtis.demo.controller;

import com.gtis.demo.core.view.GtMapPdfStamperView;
import com.gtis.demo.core.view.GtMapPdfView;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author <a href="mailto:xingxiao@gtmap.cn">xingxiaofeng</a>
 * @version2.1 2020/7/30
 * @description
 */
@Controller
public class FilePdfController {
    @Resource
    private GtMapPdfView gtMapPdfView;
    @Resource
    private GtMapPdfStamperView gtMapPdfStamperView;
    @RequestMapping("/index")
    public ModelAndView getViewPDF(Model model) {
        Map<String,String> userData = new HashMap<String,String>();
        userData.put("1", "Mahesh");
        userData.put("2", "Suresh");
        userData.put("3", "Ramesh");
        userData.put("4", "Naresh");
        model.addAttribute("userData",userData );
        return  new ModelAndView(gtMapPdfView);
    }
    @RequestMapping("/export/pdf")
    public ModelAndView exportPdf(Model model) {
        model.addAttribute("data", data());
        model.addAttribute("mergePdfFileName", "XXX贷款合同");
        return new ModelAndView(gtMapPdfView); // 与personal.hutao.view.PdfStamperView的bean id匹配
    }
    @RequestMapping("/export/pdf2")
    public ModelAndView exportPdf2(Model model) {
        model.addAttribute("data", data());
        model.addAttribute("mergePdfFileName", "XXXXXX");
        return new ModelAndView(gtMapPdfStamperView); // 与personal.hutao.view.PdfStamperView的bean id匹配
    }

    private Map<String, String> data() {
        Map<String, String> data = new HashMap<String, String>();
        data.put("borrower", "XXXFFF");
        return data;
    }
}                               
